package com.simple.configuration.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * 根目录拦截
 */
public class BasePathIntercepter implements HandlerInterceptor{
	
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		String scheme = request.getScheme();
		String serverName = request.getServerName();
		int port = request.getServerPort();
		String path = request.getContextPath();
		String basePath=scheme+"://"+serverName+":"+port+path;
		request.setAttribute("ctx",basePath);
		return HandlerInterceptor.super.preHandle(request, response, handler);
	}
	

}
